import { User, UserProfile } from '@/types/data'
import { RootAction } from '@/types/store'

const initValue: { profile:User, user: UserProfile } = {
  profile: {
    id: '',
    name: '',
    photo: '',
    art_count: 0,
    follow_count: 0,
    fans_count: 0,
    like_count: 0
  },
  user: {} as UserProfile
}
export default function profile (state = initValue, action: RootAction) {
  if (action.type === 'profile/Profile') {
    return { ...state, profile: action.payload }
  } else if (action.type === 'profile/User') {
    return { ...state, user: action.payload }
  }
  return state
}
